home *** CD-ROM | disk | FTP | other *** search
/ Family Forum 257 / SOMC Family Forum 257 - Disc 2.iso / SHOPPING.DIR / 00045_Field_45.txt < prev    next >
Text File  |  1997-05-30  |  5KB  |  194 lines

  1. -- Build Shopping List method
  2. -- NOTE: this handler has been locked on for testing in Alison's version of 
  3. -- the Shopping.dir.  ΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇóΓÇó┬Ñ
  4.  
  5. on AddToShopList vRxID
  6.   -- builds and updates a list of shopping data stored in the global gShopRxList.
  7.   -- This list provides the data for collating at the "Shopping List" module.
  8.   
  9.   global gGrabHandCursor
  10.   global gNavOffset, gShopRxList
  11.   
  12.   set RxListings = [:] -- temporary storage for this recipes shopping information
  13.   
  14.   -- UNCOMMENT THIS IN RECIPE.DIR -- ΓÇóΓÇóΓÇó
  15.   --  if the stillDown then
  16.   --    if the mouseCast = the number of cast "Title" then
  17.   --      cursor gGrabHandCursor
  18.   --    end if
  19.   --  end if
  20.   --  
  21.   --  repeat while the mouseDown
  22.   --    if rollover(gNavOffset + 8) then
  23.   --      set addRx = TRUE
  24.   --    else
  25.   --      set addRx = FALSE
  26.   --    end if
  27.   --  end repeat
  28.   --  cursor -1
  29.   
  30.   set addRx = TRUE -- COMMENT THIS OUT IN RECIPE.DIR -- ΓÇóΓÇóΓÇó
  31.   
  32.   if addRx then
  33.     -- Check for Duplicate
  34.     set dup = FALSE
  35.     if NOT voidP(gShopRxList) then
  36.       repeat with x = 1 to count(gShopRxList)
  37.         if vRxID = getAt(getAt(gShopRxList, x),1) then
  38.           set dup = TRUE
  39.           exit repeat
  40.         end if
  41.       end repeat
  42.     else
  43.       set gShopRxList = []
  44.     end if
  45.     
  46.     if not dup then
  47.       --      puppetSound 2, the number of cast "Drop"
  48.       --      updateStage
  49.       addProp (RxListings, #RecipeID, vRxID)
  50.       set Result = PointAtRec(vRxID, #Rx)
  51.       
  52.       if not Result then
  53.         addProp (RxListings, #Title, GetField(kDBTitle))
  54.         addProp (RxListings, #Servings, GetField(kDBServings))
  55.         addProp (RxListings, #Scaled, GetField(kDBServings))
  56.       end if
  57.       
  58.       -- Build Ingredients List
  59.       set IngList = []
  60.       set Result = PointAtRec(vRxID, #Ing)
  61.       
  62.       set num = 1
  63.       repeat while Result <> 2
  64.         
  65.         set NextIngrList = value("#" & "Ingredient" & num)
  66.         set newList = [:]
  67.         if GetField(kDBNoQuantity) <> "|" then
  68.           addProp (newList, #IngrLine, GetField(kDBNoQuantity))
  69.           addProp (newList, #Quantity, value(GetField(kDBQuantity)))
  70.           addProp (newList, #Unit, GetField(kDBUnit))
  71.           addProp (newList, #Category, GetField(kDBCollate))
  72.           addProp (RxListings, NextIngrList, newList)
  73.         end if
  74.         
  75.         set Result = PointNextRec(#Ing)
  76.         set num = num + 1
  77.         
  78.       end repeat
  79.       
  80.       put RxListings -- ΓÇóΓÇóΓÇó
  81.       add (gShopRxList, RxListings)
  82.       
  83.     end if
  84.   end if
  85.   
  86. end AddToShopList
  87.  
  88.  
  89.  
  90. -- Data Retrieval and Set methods for use after Recipes Sent to ShoppingList 
  91.  
  92. on GetShopRxList listPos
  93.   -- Returns the Shopping Recipe data list object at 'listPos' in the gShopRxList. 
  94.   -- Returned list contains all "Shopping List" ingredient data for that recipe.
  95.   
  96.   global gShopRxList
  97.   
  98.   return getAt(gShopRxList, listPos)
  99.   
  100. end GetShopRxList
  101.  
  102.  
  103. on GetShopRxID rxShopList
  104.   -- Returns the database recipe record ID integer for the recipe ingredient
  105.   -- data list (rxShopList).
  106.   
  107.   return getProp(rxShopList, #recipeID)
  108.   
  109. end GetShopRxID
  110.  
  111.  
  112. on GetShopRxTitle rxShopList
  113.   -- Returns the recipe title string for the recipe ingredient
  114.   -- data list (rxShopList).
  115.   
  116.   return getProp(rxShopList, #title)
  117.   
  118. end GetShopRxTitle
  119.  
  120.  
  121. on GetShopRxServings rxShopList
  122.   -- Returns the number of recipe servings string for the recipe ingredient
  123.   -- data list (rxShopList).
  124.   
  125.   return getProp(rxShopList, #servings)
  126.   
  127. end GetShopRxServings
  128.  
  129.  
  130. on GetShopRxScaled rxShopList
  131.   -- Returns number of scaled servings string for the collated recipe ingredient
  132.   -- data list (rxShopList). (NOTE: Before collating this value is the same as
  133.   -- the "servings" uncollated.
  134.   
  135.   return getProp(rxShopList, #scaled)
  136.   
  137. end GetShopRxScaled
  138.  
  139.  
  140. on SetShopRxScaled rxShopList, collatedVal
  141.   -- Sets the scaled servings value string.
  142.   -- Should be used at collate time.
  143.   
  144.   setProp(rxShopList, #scaled, collatedVal)
  145.   
  146. end SetShopRxScaled
  147.  
  148.  
  149. on GetShopRxIngrDataList rxShopList, ingrNumLine
  150.   -- Returns the ingredient sublist object from the recipe ingredient
  151.   -- data list (rxShopList).
  152.   
  153.   set thisIngredient = value("#ingredient" & ingrNumLine)
  154.   
  155.   return getProp(rxShopList, thisIngredient)
  156.   
  157. end GetShopRxIngrDataList
  158.  
  159.  
  160. on GetShopRxIngrLine rxIngrList
  161.   -- Returns the ingredient line string for the recipe ingredient
  162.   -- data list (rxShopList).
  163.   
  164.   return getProp(rxIngrList, #IngrLine)
  165.   
  166. end GetShopRxIngrLine
  167.  
  168.  
  169. on GetShopRxIngrQty rxIngrList
  170.   -- Returns the database recipe record ID integer for the recipe ingredient
  171.   -- data list (rxShopList).
  172.   
  173.   return getProp(rxIngrList, #quantity)
  174.   
  175. end GetShopRxIngrQty
  176.  
  177.  
  178. on GetShopRxIngrUnit rxIngrList
  179.   -- Returns the servings unit float value for the recipe ingredient
  180.   -- data list (rxShopList).
  181.   
  182.   return getProp(rxIngrList, #unit)
  183.   
  184. end GetShopRxIngrUnit
  185.  
  186.  
  187. on GetShopRxIngrCat rxIngrList
  188.   -- Returns the category string for the recipe ingredient
  189.   -- data list (rxShopList).
  190.   
  191.   return getProp(rxIngrList, #category)
  192.   
  193. end GetShopRxIngrCat
  194.